Skip to content

Fix #2146: Make nested implicit function types work #2235

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Apr 26, 2017

Conversation

odersky
Copy link
Contributor

@odersky odersky commented Apr 12, 2017

Fix problems related to implicit function types.

  1. Propagate expected type when typing an implicit closure.
    This is necessary to recursively apply eta expansion in the
    case of nested implicit functions.

  2. Recursively transform definitions and accesses in shortcurImplicits

  3. Generalize normalize to handle implicit function types

Review by @b-studios?

@odersky
Copy link
Contributor Author

odersky commented Apr 12, 2017

@felixmulder It fails because it does not find dotty.tools.dotc.ParallelTesting.

odersky added 3 commits April 12, 2017 15:58
1. Propagate expected type when typing an implicit closure.
   This is necessary to recursively apply eta expansion in the
   case of nested implicit functions.

2. Generalize match pattern in shortcutImplicits.
   This is necessary to avoid a crash.
This is necessary so that we can typecheck the last 4 statements
of i2146.scala.
It was not necessary to widen it, after all.
@b-studios
Copy link
Contributor

@odersky Thanks alot for addressing the bug! Judging from the output of -Xprint:shortcutImplicits this looks really good to me. Finally we can use type aliases like:

type using[A, B] = implicit B => A
type and[A, B] = implicit B => A
def foo: Int using A and B = { ... }

Maybe add some tests on partially eta-expanded implicits?

Variant 1 - Outside-In (✔)

def foo: implicit A => implicit B => Int = { implicit a: A => ... }

Variant 2 - Inside-Out (✘)

def foo: implicit A => implicit B => Int = { implicit b: B => ... }

As I still know too little of the dotty compiler, I can't say much about how the code changes affect other existing functionality. You probably want to ask a second reviewer for that.

@Blaisorblade
Copy link
Contributor

Thanks for dotty-staging#2.

As I still know too little of the dotty compiler, I can't say much about how the code changes affect other existing functionality. You probably want to ask a second reviewer for that.

👍. But FWIW, more recursion in normalize after taking a step is generally sensible.

@felixmulder felixmulder merged commit 2f85c86 into scala:master Apr 26, 2017
@allanrenucci allanrenucci deleted the fix-#2146 branch December 14, 2017 19:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants